package net.labdemo.entity;

import java.util.Arrays;
import java.util.List;

public class Role {
	/**
	 * 标识
	 */
	private int symbol;
	/**
	 * 描述
	 */
	private String descrip;
	
	public int getSymbol() {
		return symbol;
	}
	public void setSymbol(int symbol) {
		this.symbol = symbol;
	}
	public String getDescrip() {
		return descrip;
	}
	public void setDescrip(String descrip) {
		this.descrip = descrip;
	}
	public Role(int symbol, String descrip) {
		super();
		this.symbol = symbol;
		this.descrip = descrip;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((descrip == null) ? 0 : descrip.hashCode());
		result = prime * result + symbol;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Role other = (Role) obj;
		if (descrip == null) {
			if (other.descrip != null)
				return false;
		} else if (!descrip.equals(other.descrip))
			return false;
		if (symbol != other.symbol)
			return false;
		return true;
	}
	
	public static Role getRoleInstance(int symbol){
		Role r=null;
		switch(symbol){
		case 1:
			r=new Role(1,"公开");
			break;
		case 2:
			r=new Role(2,"好友");
			break;
		case 3:
			r=new Role(3,"群组");
			break;
		case 4:
			r=new Role(4,"自已");
			break;
		}
		return r;
	}
	public static List<Role> getDefined(){
		return Arrays.asList(new Role(1, "公开"),new Role(2, "好友"),new Role(3, "群组"),new Role(4, "自已"));
	}
}
